<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="./../template/main.xhtml">
        <ui:define name="content">
            <p:panel styleClass="FORM_HEADER_NEW">
                <h:outputText value="Item Estimation List" styleClass="FORM_HEADER_NEW"/>    
            </p:panel>
            <br></br>
            <h:form>
                <h:panelGroup>
                    <p:outputLabel for="estimationId" value="Estimation:"
                                   styleClass="SIMPLE_LINE"/>
                    <p:selectOneMenu id="estimationId" 
                                     value="#{itemEstimationController.itemEstimationDTO.estimationId}"
                                     style="width: 220px;">
                        <f:selectItems value="#{itemEstimationController.estimationList}" var="estimation"
                                       itemValue="#{estimation.id}" itemLabel="#{estimation.name}" />
                        <p:ajax listener="#{itemEstimationController.reloadAllEstimatedTimeList}"
                                update="itemEstimationTable"/>
                    </p:selectOneMenu>
                </h:panelGroup>
                <p:dataTable id="itemEstimationTable" value="#{itemEstimationController.itemEstimationList}" 
                             var="item"
                             paginator="true" paginatorAlwaysVisible="false" paginatorPosition="bottom"
                             rowStyleClass="SIMPLE_LINE"
                             style="margin-top: 10px;">
                    <p:column>
                        <f:facet name="header">Id</f:facet>
                        <h:outputText value="#{item.id}" styleClass="COLUMN"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">Item</f:facet>
                        <h:outputText value="#{item.itemName}" styleClass="COLUMN"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">Job</f:facet>
                        <h:outputText value="#{item.jobName}" styleClass="COLUMN"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">Quantity</f:facet>
                        <h:outputText value="#{item.quantity}" styleClass="COLUMN"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">Duration Value</f:facet>
                        <h:outputText value="#{item.durationValue}" styleClass="COLUMN"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">Duration Type</f:facet>
                        <h:outputText value="#{item.durationTypeName}" styleClass="COLUMN"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">Total Time</f:facet>
                        <h:outputText value="#{item.itemTotalTime}" styleClass="COLUMN"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">Action</f:facet>
                        <h:commandLink value="View" action="#{itemEstimationController.view}">
                            <f:param name="itemEstimationId" value="#{item.id}"/>
                        </h:commandLink>
                        <h:outputText value=" "/>
                        <h:commandLink value="Edit" action="#{itemEstimationController.edit}">
                            <f:param name="itemEstimationId" value="#{item.id}"/>
                        </h:commandLink>
                    </p:column>
                </p:dataTable>
            </h:form>
        </ui:define>
    </ui:composition>
</html>